<?php

namespace app\common\model;

use think\Db;
use think\Model;

class Menu extends Model
{
    //事件观察者
    protected $observerClass = 'app\common\event\Menu';
    protected $autoWriteTimestamp = true;
    protected $type = [
        'create_time'    =>  'integer',
        'update_time'     =>  'integer',
    ];
    public function parent()
    {
        return $this->belongsTo(Menu::class,'parent_id');
    }

    public function children()
    {
        return $this->hasMany(Menu::class, 'parent_id');
    }

}
